from util.EyouAutoMation import EyouAutoMation
from DrissionPage import ChromiumPage
import pandas as pd

# 创建页面对象，并启动或接管浏览器
page = ChromiumPage()
amt = EyouAutoMation(page)

def main():
    __name__ = "__main__"
    url  ='http://www.jiangshuntech.com/login.php'
    username = 'admin'
    password = 'yyl1235790'
    seo_xfile = r"E:\project\documents\webseo.xlsx"
    article_release(url,username,password,seo_xfile)

def article_release(url,username,password,seo_xfile):
    page.wait(0.5)
    if(not page.ele('#Archives_index',timeout=0.2)):
        amt.start(url,username,password)
    if(not page.ele('#tree_16_span',timeout=0.2)):
        amt.article_manage()
    # 读取本地excel文件
    data = pd.read_excel(seo_xfile)
    for i in range(1,len(data)):
        seo_data={'title':data['title4'][i],'keywords':data['keywords'][i],'litpic':data['pic_path'][i]}
        amt.article_copy(seo_data)
        if i!=0 and i%15==0:
            # 刷新页面
            page.refresh()
            page.wait(1)
            amt.article_manage()

if __name__ == "__main__":
    main()